/**
 * Created by Francis.LW on 2017/10/20.
 *
 * 救援公司服务接口
 */
import {postRequest, getRequest} from '@/common/request'
import {urls} from './url'

const rescueCompanyApi = urls.rescueCompany

function listAllRescueCompany(param, success, complete) {
  postRequest(rescueCompanyApi.listAllRescueCompany, {}, param, success, complete)
}

function listOperationRescueCompany(param, page, pageSize, success, complete) {
  postRequest(rescueCompanyApi.listOperationRescueCompany + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listCompanyPayables(param, page, pageSize, success, complete) {
  postRequest(rescueCompanyApi.listCompanyPayables + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}

function listRescueCompany(param, page, pageSize, success, complete) {
  postRequest(rescueCompanyApi.listRescueCompany + '?currentpage=' + page + '&pagesize=' + pageSize, {}, param, success, complete)
}


function updateBaseRescueCompany(id, param, success, complete) {
  postRequest(rescueCompanyApi.updateBaseRescueCompany + id, {}, param, success, complete)
}

function mergeFormData(id, param, success, complete) {
  postRequest(rescueCompanyApi.mergeFormData + id, {}, param, success, complete)
}

function getRescueCompanyById(id, success, complete) {
  getRequest(rescueCompanyApi.getRescueCompanyById + id, {}, success, complete)
}

function getOperationById(id, success, complete) {
  getRequest(rescueCompanyApi.getOperationById + id, {}, success, complete)
}

function setWorkTemplate(id, templateId, success, complete) {
  postRequest(rescueCompanyApi.setWorkTemplate + id, {templateId: templateId}, {}, success, complete)
}

function removeRescueCompany(ids, success, complete) {
  postRequest(rescueCompanyApi.removeRescueCompany, {}, ids, success, complete)
}

function deleteSingleRescueCompany(id, success, complete) {
  let ids = []
  ids.push(id)
  removeRescueCompany(ids, success, complete)
}

function unfreezeCommission(param, success, complete) {
  postRequest(rescueCompanyApi.unfreezeCommission, {}, param, success, complete)
}

function adjustmentCommission(param, success, complete) {
  postRequest(rescueCompanyApi.adjustmentCommission, {}, param, success, complete)
}

function adjustmentIntegral(param, success, complete) {
  postRequest(rescueCompanyApi.adjustmentIntegral, {}, param, success, complete)
}

export default {
  mergeFormData,
  listAllRescueCompany,
  listCompanyPayables,
  listOperationRescueCompany,
  listRescueCompany,
  updateBaseRescueCompany,
  getRescueCompanyById,
  getOperationById,
  setWorkTemplate,
  removeRescueCompany,
  deleteSingleRescueCompany,
  unfreezeCommission,
  adjustmentCommission,
  adjustmentIntegral
}
